<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<meta charset="UTF-8">
<title>detailList</title>
<link rel="stylesheet" href="css/informationList.css" />
<script src="js/jquery-3.3.1.js"></script>
<script src="js/information.js"></script>
<script>
$(function() {
	$.get("sort/getSort", function(res) {
		var sel = $("#select_id");
		var option = "<option value='0'>全部</option>";
		var v="${SORTID}";
		sel.append(option);
		$(res).each(
				function() {
					if(this.id==v){
						var option = "<option value='"+this.id+"' selected>" + this.name
						+ "</option>";
						sel.append(option);	
					}
					var option = "<option value='"+this.id+"'>" + this.name
							+ "</option>";
					sel.append(option);
				});
		}
	, 'json');
	$("#select_id").blur(function(){
		var op=$("#select_id").val();
		location="detail/detailList?sortId="+op;
	});
});
</script>
</head>
<body>
	<div align="center">
		<span>请选择商品分类</span> <select name="sortId" id="select_id" style=" width:11em;height:2em">
		</select>
		<table id="table">
			<tr class="in">
				<th width="5%">商品编号</th>
				<th width="5%">商品名称</th>
				<th width="5%">商品分类</th>
				<th width="5%">产地</th>
				<th width="10%">生产日期</th>
				<th width="5%">单价（元）</th>
				<th width="5%">剩余数量</th>
				<th width="5%">购买</th>
			</tr>
			<c:forEach items="${PAGE.list }" var="de">
				<tr>
					<td>${de.id }</td>
					<td>${de.name }</td>
					<td>${de.sortId }</td>
					<td>${de.address }</td>
					<td>${de.price }</td>
					<fmt:formatDate var="time" pattern="yyyy-MM-dd"
						value="${de.createDate }" />
					<td>${time }</td>
					<td>${de.remaining }</td>
					<td><a href="detail/toUpdateGoods?id=${de.id}&sortId=${de.sortId}">购买</a></td>
				</tr>
			</c:forEach>
		</table>
		<div class="page">
			<a href="detail/detailList?pageNum=1" class="firstPage">首页</a>
			<a href="detail/detailList?pageNum=${PAGE.pageNum-1}"
				class="prevPage">上一页</a> <a
				href="detail/detailList?pageNum=${PAGE.pageNum+1}"
				class="nextPage">下一页</a> <a
				href="detail/detailList?pageNum=${PAGE.totalPage}"
				class="lastPage">末页&nbsp;</a> <span>&nbsp;第</span> ${PAGE.pageNum} <span>页/共</span>
			${PAGE.totalPage} <span>页</span>
		</div>
	</div>
</body>
</html>